# 测试真实医疗分析功能
Write-Host "=== 智慧医疗 RAG 系统 - 真实医疗分析测试 ===" -ForegroundColor Green

# 等待 API 启动
Write-Host "等待 API 启动..." -ForegroundColor Yellow
Start-Sleep -Seconds 10

# 测试用例1：胸痛患者
Write-Host "`n=== 测试用例1：胸痛患者 ===" -ForegroundColor Cyan
$chestPainRequest = @{
    chiefComplaint = "胸痛，伴有胸闷"
    symptoms = @("胸痛", "胸闷", "心悸", "气短")
    vitalSigns = @{
        bloodPressure = "140/90"
        heartRate = 110
        temperature = 36.8
        respiratoryRate = 20
        oxygenSaturation = 95
    }
    medicalHistory = "高血压病史3年"
}

try {
    $response1 = Invoke-RestMethod -Uri "https://localhost:56704/api/Triage/analyze" -Method Post -Body ($chestPainRequest | ConvertTo-Json -Depth 10) -ContentType "application/json"
    Write-Host "✓ 胸痛患者分析完成" -ForegroundColor Green
    Write-Host "推荐科室: $($response1.recommendation.recommendedDepartment)" -ForegroundColor Yellow
    Write-Host "优先级: $($response1.recommendation.priority)" -ForegroundColor Yellow
    Write-Host "推理过程: $($response1.recommendation.reasoning)" -ForegroundColor Yellow
    Write-Host "置信度: $($response1.recommendation.confidence)" -ForegroundColor Yellow
} catch {
    Write-Host "❌ 胸痛患者分析失败: $($_.Exception.Message)" -ForegroundColor Red
}

# 测试用例2：头痛患者
Write-Host "`n=== 测试用例2：头痛患者 ===" -ForegroundColor Cyan
$headacheRequest = @{
    chiefComplaint = "头痛，伴有恶心"
    symptoms = @("头痛", "恶心", "呕吐", "头晕")
    vitalSigns = @{
        bloodPressure = "120/80"
        heartRate = 75
        temperature = 38.2
        respiratoryRate = 18
        oxygenSaturation = 98
    }
    medicalHistory = "无特殊病史"
}

try {
    $response2 = Invoke-RestMethod -Uri "https://localhost:56704/api/Triage/analyze" -Method Post -Body ($headacheRequest | ConvertTo-Json -Depth 10) -ContentType "application/json"
    Write-Host "✓ 头痛患者分析完成" -ForegroundColor Green
    Write-Host "推荐科室: $($response2.recommendation.recommendedDepartment)" -ForegroundColor Yellow
    Write-Host "优先级: $($response2.recommendation.priority)" -ForegroundColor Yellow
    Write-Host "推理过程: $($response2.recommendation.reasoning)" -ForegroundColor Yellow
    Write-Host "置信度: $($response2.recommendation.confidence)" -ForegroundColor Yellow
} catch {
    Write-Host "❌ 头痛患者分析失败: $($_.Exception.Message)" -ForegroundColor Red
}

# 测试用例3：腹痛患者
Write-Host "`n=== 测试用例3：腹痛患者 ===" -ForegroundColor Cyan
$abdominalPainRequest = @{
    chiefComplaint = "剧烈腹痛"
    symptoms = @("腹痛", "恶心", "呕吐", "发热")
    vitalSigns = @{
        bloodPressure = "130/85"
        heartRate = 90
        temperature = 37.8
        respiratoryRate = 22
        oxygenSaturation = 96
    }
    medicalHistory = "无特殊病史"
}

try {
    $response3 = Invoke-RestMethod -Uri "https://localhost:56704/api/Triage/analyze" -Method Post -Body ($abdominalPainRequest | ConvertTo-Json -Depth 10) -ContentType "application/json"
    Write-Host "✓ 腹痛患者分析完成" -ForegroundColor Green
    Write-Host "推荐科室: $($response3.recommendation.recommendedDepartment)" -ForegroundColor Yellow
    Write-Host "优先级: $($response3.recommendation.priority)" -ForegroundColor Yellow
    Write-Host "推理过程: $($response3.recommendation.reasoning)" -ForegroundColor Yellow
    Write-Host "置信度: $($response3.recommendation.confidence)" -ForegroundColor Yellow
} catch {
    Write-Host "❌ 腹痛患者分析失败: $($_.Exception.Message)" -ForegroundColor Red
}

# 测试用例4：呼吸困难患者
Write-Host "`n=== 测试用例4：呼吸困难患者 ===" -ForegroundColor Cyan
$dyspneaRequest = @{
    chiefComplaint = "呼吸困难，气短"
    symptoms = @("呼吸困难", "气短", "咳嗽", "胸闷")
    vitalSigns = @{
        bloodPressure = "125/80"
        heartRate = 95
        temperature = 37.5
        respiratoryRate = 25
        oxygenSaturation = 88
    }
    medicalHistory = "哮喘病史5年"
}

try {
    $response4 = Invoke-RestMethod -Uri "https://localhost:56704/api/Triage/analyze" -Method Post -Body ($dyspneaRequest | ConvertTo-Json -Depth 10) -ContentType "application/json"
    Write-Host "✓ 呼吸困难患者分析完成" -ForegroundColor Green
    Write-Host "推荐科室: $($response4.recommendation.recommendedDepartment)" -ForegroundColor Yellow
    Write-Host "优先级: $($response4.recommendation.priority)" -ForegroundColor Yellow
    Write-Host "推理过程: $($response4.recommendation.reasoning)" -ForegroundColor Yellow
    Write-Host "置信度: $($response4.recommendation.confidence)" -ForegroundColor Yellow
} catch {
    Write-Host "❌ 呼吸困难患者分析失败: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "`n=== 测试完成 ===" -ForegroundColor Green
Write-Host "现在您可以看到系统提供了真实的医疗分析和建议！" -ForegroundColor Cyan
Write-Host "包括：症状分析、疾病诊断、科室推荐、风险评估、治疗建议等" -ForegroundColor Cyan 